﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using BLL;

namespace TimViec.NTD.UserControls
{
    public partial class TuVanNgheNghiep : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }
        public void LoadData()
        {
            var db = Connect.GetDataContext<TimViecDataContext>("Strconnect");
            var query = (from bv in db.tbl_Articles.Where(k => k.Value_config == "TVNN")
                         select new ArticleDao
                                    {
                                        ArticleId = bv.ArticleId,
                                        URL = bv.URL,
                                        ArticleName = bv.ArticleName,
                                        Description = bv.Description,
                                        CreateDate = bv.CreateDate,
                                        Images = bv.Images,
                                    }).OrderByDescending(k => k.CreateDate).Take(1);
            List<ArticleDao> l = query.ToList();
            if (l.Count > 0)
            {
                lbTieuDe.Text = "<h3><a href='/tu-van-nghe-nghiep" + l[0].ArticleId +"/"+ l[0].URL + ".html'>" + l[0].ArticleName+ "</a></h3>";
                lbImage.Text = "<a href='/tu-van-nghe-nghiep" + l[0].ArticleId +"/"+ l[0].URL + ".html'><img src='" +
                               l[0].Images + "' /></a>";
                lbTomTat.Text = l[0].Description;
            }
            //
            rptTVNN.DataSource = BLL.ArticleHelper.Top_BV_Valueconfig("TVNN",1,8);
            rptTVNN.DataBind();

        }
    }
}